<!DOCTYPE html>
<head>
    <meta charset="utf-8">
    <title>ECharts</title>
    <%@ page contentType="text/html;charset=UTF-8" language="java" %>
</head>
<body>
<!-- 为ECharts准备一个具备大小（宽高）的Dom -->
<div id="main" style="width: 700px;height:600px;"></div>
<!-- ECharts单文件引入 -->
<jsp:include page="${pageContext.request.contextPath}/commen/commen.jsp"></jsp:include>
<script type="text/javascript">
    // 基于准备好的dom，初始化echarts图表
    var myChart = echarts.init(document.getElementById('main'));

    $.post("/shangpin/querytype",function (data) {
        var aa =[];
        var bb =[];
        $.each(data.sp,function (index,item) {
            aa.push(item.xname)
        })

        $.each(data.sp,function (index,item) {
            var v ={name:item.xname,value:item.spshu}
            bb.push(v);
        })

            myChart.setOption({
            title : {
                text: '商品类型销售量',
                subtext: '',
                x:'center'
            },
            tooltip : {
                trigger: 'item',
                formatter: "{a} <br/>{b} : {c} ({d}%)"
            },
            legend: {
                orient : 'vertical',
                x : 'left',
                data:aa
            },
            toolbox: {
                show : true,
                feature : {
                    dataView : {show: true, readOnly: false},
                    magicType : {
                        show: true,
                        type: ['pie', 'funnel'],
                        option: {
                            funnel: {
                                x: '25%',
                                width: '50%',
                                funnelAlign: 'left',
                                max: 1548
                            }
                        }
                    },
                    restore : {show: true},
                    saveAsImage : {show: true}
                }
            },
            calculable : true,
            series : [
                {
                    name:'访问来源',
                    type:'pie',
                    radius : '55%',
                    center: ['50%', '60%'],
                    data:bb
                }
            ]
        })

    })




</script>
</body>